package com.seelyn.rhea.integrate.spring;

import com.seelyn.rhea.mvc.internal.PathRepeatException;
import com.seelyn.rhea.mvc.internal.RheaFactory;
import com.seelyn.rhea.mvc.internal.RouteFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @author linfeng
 * @since 2016/1/28
 */
public class SpringRouteFactory {

    private RouteFactory factory = RheaFactory.getInstance();

    private List<InternalRouteImpl> routeList = new ArrayList<>();
    private List<InternalFilterImpl> filterList = new ArrayList<>();

    public void initRoute() throws PathRepeatException {
        if (!routeList.isEmpty()) {
            for (InternalRouteImpl route: routeList) {
                factory.addRoute(route.getMethod(), route);
            }
        }

         if (!filterList.isEmpty()) {
            for (InternalFilterImpl filter: filterList) {
                factory.addFilter(filter.getMethod(), filter);
            }
        }
    }

    public void setRouteList(List<InternalRouteImpl> routeList) {
        this.routeList = routeList;
    }

    public void setFilterList(List<InternalFilterImpl> filterList) {
        this.filterList = filterList;
    }

}
